home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / MacTCP / MacTCP Developer Tools / 802 LAP / LAP802.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-21  |  6.1 KB  |  201 lines  |  [TEXT/MPS ]

  1. /* LAP802.h contains IEEE 802.3 structure definitions
  2.  
  3.    (c) Copyright 1990-91 by Apple Computer, Inc.  All rights reserved.
  4.    
  5. */
  6.  
  7. /*
  8.     1.2        10/11/90    Rajesh    modified for IEEE 802.3 LAP.
  9. */
  10.  
  11. #include "LAP802Arp.h"
  12.  
  13. /* define structure for collecting statistics on IEEE 802.3 LAP driver */
  14.  
  15. struct VBLTaskA5 {
  16.     VBLTask VBL;
  17.     Ptr vblA5;
  18.     };
  19.  
  20. struct type_stats {
  21.     long pktin;                        /* total number of packets received */
  22.     long broadcast;                    /* number of broadcasts received */
  23.     long pktout;                    /* total number of packets sent */
  24.     };
  25.  
  26. struct Lap802_stats {
  27.     long unknown;                    /* unknown IEEE 802.3 type values */
  28.     struct type_stats arp;            /* IEEE 802.3 ARP type statistics */
  29.     struct type_stats ip;            /* IEEE 802.3 IP type statistics */
  30.     };
  31.  
  32. typedef struct Lap802_addr {
  33.     b_16 lap_hi;
  34.     b_32 lap_lo;
  35.     } Lap802_addr;
  36.  
  37. typedef struct LLC_SNAP_header {
  38.     b_8                lap_dsap;    /* Destination Service Access Point */
  39.     b_8                lap_ssap;    /* Source Service Access Point */
  40.     b_8                lap_cntl;    /* control */
  41.     b_8                lap_orghi;    /* organization code, high byte */
  42.     b_16            lap_orglo;    /* organization code, 2 low bytes */
  43.     b_16            lap_type;    /* Ethertype */
  44.     } LLC_SNAP_header;
  45.  
  46. typedef struct arp_entry {
  47.     short        age;            /* cache aging field */
  48.     b_16        protocol;        /* Protocol type */
  49.     ip_addr     ip_address;        /* IP address */
  50.     Lap802_addr    lap_address;    /* matching IEEE 802.3 address */
  51.     };
  52.  
  53. /* IEEE 802.3 ARP packet format */
  54. typedef struct arp_header {
  55.     b_16        arp_hardware;       /* Format of hardware address */
  56.     b_16        arp_protocol;       /* Format of protocol address */
  57.     b_8            arp_hlen;           /* Hardware address length */
  58.     b_8               arp_plen;           /* protocol address length */
  59.     b_16        arp_opcode;
  60.     struct Lap802_addr    arp_sha;    /* ARP RARP sender hardware address */
  61.     ip_addr     arp_spa;            /* ARP RARP sender IP address */
  62.     struct Lap802_addr    arp_tha;    /* ARP RARP target hardware address */
  63.     ip_addr     arp_tpa;               /* ARP RARP target IP address */
  64. } ARP_header;
  65.  
  66. /* ARP parameters */
  67. #define ARP_TABLE_SIZE    20            /* number of ARP table entries */
  68. #define MAX_ARP_COUNT    3           /* Max. number of ARP transmitted */
  69.                                     /*  before dest. is declared unknown */
  70.  
  71. #define ARP_TX_INTRVL    2            /* Time interval between ARP transmission */
  72.  
  73.  
  74. struct arp_info {
  75.     short timer;                    /* ARP retransmission timer */
  76.     short rtx;                        /* number of retransmissions */
  77.     ip_addr addr;                    /* IP address being ARPed */
  78.     };
  79.  
  80.  
  81. /* IEEE 802.3 LAP information structure */
  82. struct Lap802Info {
  83.     LAPINFO                                /* generic LAP info */
  84.         /* IEEE 802.3-specific LAP variables */
  85.     Lap802_addr     our_lap_addr;        /* IEEE 802.3 address for this interface */
  86.     Lap802_addr     lap_broadcast_addr;    /* IEEE 802.3 broadcast address */
  87.     struct arp_header arp_rcv;            /* buffer for receiving ARP packets */
  88.     struct ipbuf *arp_ipb;                /* buffer for sending ARP requests */
  89.     struct QHdr arp_q;                    /* queue of pkts waiting for ARP resolution */
  90.     struct arp_entry arp_table[ARP_TABLE_SIZE];        /* IEEE 802.3 to IP address table */    
  91.     struct VBLTaskA5 arp_vrt_info;        /* VBL info */
  92.     struct Lap802_stats Lap802_stats;        /* various LAP statistics */
  93.     };
  94.  
  95. /* define I/O Control equates for accessing/controlling the IEEE 802.3 driver */
  96. #define    TAttachPH        247         /* Attach protocol handler */
  97. #define    TDetachPH        248         /* Detach protocol handler */
  98. #define    TWrite            249         /* Write */
  99. #define    TRead            250         /* Read */
  100. #define    TRdCancel        251         /* Cancel read */
  101. #define    TGetInfo        252         /* Get info */
  102. #define    TSetGeneral     253            /* Set "general" mode */
  103.  
  104. /* define I/O param block for accessing IEEE 802.3 driver */
  105. struct Lap802PB {
  106.     QElem *qlink;
  107.     short        qType;
  108.     short        ioTrap;
  109.     Ptr            ioCmdAddr;
  110.     ProcPtr        ioCompletion;
  111.     OSErr        ioResult;
  112.     char        *ioNamePtr;
  113.     short        ioVRefNum;
  114.     short        ioRefNum;
  115.     short        csCode;                /* control code */
  116.     union {
  117.         struct {
  118.             short    protocolType;    /* protocol type */
  119.             ProcPtr    PHaddress;        /* protocol handler address */
  120.             } TAttachPB;
  121.         struct {
  122.             short    protocolType;    /* protocol type */
  123.             } TDetachPB;
  124.         struct {
  125.             short    padding;        /* padding */
  126.             struct wds     *wdsPtr;    /* pointer to write data structure */
  127.             } TWritePB;
  128.         struct {
  129.             short    protocolType;    /* protocol type */
  130.             char     *bufPtr;        /* read buffer pointer */
  131.             short    bufSize;        /* buffer size */
  132.             short    dataSize;        /* data size */
  133.             } TReadPB;
  134.         struct {
  135.             short    padding;        /* padding */
  136.             char     *infoPtr;        /* pointer to info buffer */
  137.             short    bufSize;        /* buffer size */
  138.             } TGetInfoPB;
  139.         } csParam;
  140.     };
  141.  
  142. struct wds {
  143.     short    length;
  144.     Ptr        pointer;
  145.     };
  146.  
  147.  
  148. /* IEEE 802.3 header format */
  149. typedef struct Lap802_header {
  150.     struct Lap802_addr    lap_dest;    /* 6 bytes destination address */
  151.     struct Lap802_addr  lap_src;    /* 6 bytes source address */
  152.     b_16                 lap_len;    /* 802.3 MAC header, length field */
  153.     struct    LLC_SNAP_header    lap_ls;    /* 8 bytes LLC and SNAP header */
  154. } Lap802_header;
  155.  
  156. typedef struct Enet_addr {
  157.     b_16 en_hi;
  158.     b_32 en_lo;
  159.     } Enet_addr;
  160.  
  161. /* Ethernet header format */
  162. typedef struct Enet_header {
  163.     struct Enet_addr    en_dest;    /* 6 bytes destination address */
  164.     struct Enet_addr       en_src;        /* 6 bytes source address */
  165.     b_16                 en_type;    /* protocol type */
  166. } Enet_header;
  167.  
  168. /* Maximum IEEE 802.3 packet size */
  169. #define    MAX_LAP802_PKT    1522        /* maximum IEEE 802.3 packet size */
  170. #define    LAP802SPEED        10000000    /* maximum IEEE 802.3 speed 10 MB */
  171.  
  172. #define LAP_IP           0x0800
  173. #define LAP_ARP          0x0806
  174. #define LAP_RARP         0x8035
  175.  
  176. #define    HEX_0            0x00
  177. #define    HEX_1            0x01
  178. #define    HEX_3            0x03
  179. #define    HEX_5            0x05
  180. #define    HEX_6            0x06
  181. #define    HEX_8            0x08
  182. #define    HEX_35            0x35
  183. #define    HEX_80            0x80
  184. #define    HEX_AA            0xAA
  185.  
  186. /* Functions prototypes */
  187.  
  188. extern OSErr Arp_init(struct Lap802Info *lap);
  189. extern void Arp_read_ph(struct rdStruct *rds);
  190. extern void RARP_read_ph(struct rdStruct *rds);
  191. extern struct Lap802_addr *IP_to_Lap802(struct Lap802Info *lap, ip_addr addr);
  192. extern void del_arp_entry(struct Lap802Info *lap, ip_addr addr);
  193. extern void SendARP (struct Lap802Info *lap, int arp_code, ip_addr ip_dest, Lap802_addr *lap_dest);
  194. extern void Arp_close(struct Lap802Info *lap);
  195. extern OSErr Lap802_writeit(struct Lap802Info *lap, struct ipbuf *ipb);
  196.  
  197. /* definitions for MacsBug debugger */
  198.  
  199. // pascal void Debugger() extern 0xa9ff;
  200. // pascal void DebugStr(msg) char *msg; extern 0xabff;
  201.